#ifndef WNDITEM_H
#define WNDITEM_H

#include <QObject>
#include <QList>
#include <windows.h>
#include <QSharedPointer>
#include <Qmap>

class QSettings;
class QMenu;
class QListWidget;
class QAction;
//struct WndHotKey
//{
//	DWORD	dwModifier;
//	WORD	wKey;
//};

union WndHotKey
{
	struct
	{
		WORD wModifier;
		WORD wKey;
	} W;
	DWORD dwHotKey;
};

///////////////////////////////////////////////////////////
class WndItem : public QObject
{
	Q_OBJECT;
private:
	HWND m_hWnd;
	WndHotKey m_hotKey;
	QString m_sWndTitle;
	QString m_sClassName; // the identifier for the hot key

public:
	explicit WndItem(const HWND hWnd, const QString &sTitle, const QString &sWndClassName);

	QString hotKey() const;
	void setHotKey(const QString & sHotKey);

	HWND hwnd() const {return m_hWnd;}
	QString title() const {return m_sWndTitle;}
	QString className() const {return m_sClassName;}

	void loadHotKey(QSettings & settings);
	void saveHotKey(QSettings & settings);

public slots:
	void showWindow(bool bShow = true);

private:
	WndItem(){}
};
///////////////////////////////////////////////////////////
typedef QSharedPointer<WndItem> SPWndItem;
typedef QMap<HWND, SPWndItem> WndItemsMap;

class WndItems : public QObject
{
	Q_OBJECT;
private:
	WndItemsMap m_map;
	QSettings	* m_pSettings; // ? should be shared ptr
	DWORD m_dwStyleFilter;
public:
	WndItems(QSettings * pSettings, QObject * pParent = 0);
	void update(const DWORD dwStyles);
	void populateMenu(QMenu & menu, QAction * before);
	void populateListWidget(QListWidget & list);
private:
	static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
};
///////////////////////////////////////////////////////////

#endif // WNDITEM_H
